home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_usrdoc / BZIP2 / BZIP2.TXT < prev    next >
Text File  |  1999-09-17  |  17KB  |  356 lines

  1.  
  2. bzip2(1)                                                 bzip2(1)
  3.  
  4.  
  5. NAME
  6.        bzip2, bunzip2 - a block-sorting file compressor, v0.9.0
  7.        bzcat - decompresses files to stdout
  8.        bzip2recover - recovers data from damaged bzip2 files
  9.  
  10.  
  11. SYNOPSIS
  12.        bzip2 [ -cdfkstvzVL123456789 ] [ filenames ...  ]
  13.        bunzip2 [ -fkvsVL ] [ filenames ...  ]
  14.        bzcat [ -s ] [ filenames ...  ]
  15.        bzip2recover filename
  16.  
  17.  
  18. DESCRIPTION
  19.        bzip2  compresses  files  using the Burrows-Wheeler block-
  20.        sorting text compression algorithm,  and  Huffman  coding.
  21.        Compression  is  generally  considerably  better than that
  22.        achieved by more conventional LZ77/LZ78-based compressors,
  23.        and  approaches  the performance of the PPM family of sta-
  24.        tistical compressors.
  25.  
  26.        The command-line options are deliberately very similar  to
  27.        those of GNU Gzip, but they are not identical.
  28.  
  29.        bzip2  expects  a list of file names to accompany the com-
  30.        mand-line flags.  Each file is replaced  by  a  compressed
  31.        version  of  itself,  with  the  name "original_name.bz2".
  32.        Each compressed file has the same  modification  date  and
  33.        permissions  as  the corresponding original, so that these
  34.        properties can  be  correctly  restored  at  decompression
  35.        time.  File name handling is naive in the sense that there
  36.        is no mechanism for preserving original file  names,  per-
  37.        missions  and  dates  in filesystems which lack these con-
  38.        cepts, or have serious file name length restrictions, such
  39.        as MS-DOS.
  40.  
  41.        bzip2  and  bunzip2 will by default not overwrite existing
  42.        files; if you want this to happen, specify the -f flag.
  43.  
  44.        If no file names  are  specified,  bzip2  compresses  from
  45.        standard  input  to  standard output.  In this case, bzip2
  46.        will decline to write compressed output to a terminal,  as
  47.        this  would  be  entirely  incomprehensible  and therefore
  48.        pointless.
  49.  
  50.        bunzip2 (or bzip2 -d ) decompresses and restores all spec-
  51.        ified files whose names end in ".bz2".  Files without this
  52.        suffix are ignored.  Again, supplying no filenames  causes
  53.        decompression from standard input to standard output.
  54.  
  55.        bunzip2 will correctly decompress a file which is the con-
  56.        catenation of two or more compressed files.  The result is
  57.        the concatenation of the corresponding uncompressed files.
  58.        Integrity testing (-t) of concatenated compressed files is
  59.        also supported.
  60.  
  61.        You  can also compress or decompress files to the standard
  62.        output by giving the -c flag.  Multiple files may be  com-
  63.        pressed and decompressed like this.  The resulting outputs
  64.        are fed sequentially to stdout.  Compression  of  multiple
  65.        files  in this manner generates a stream containing multi-
  66.        ple compressed file representations.  Such a stream can be
  67.        decompressed  correctly  only  by  bzip2  version 0.9.0 or
  68.        later.  Earlier versions of bzip2 will stop  after  decom-
  69.        pressing the first file in the stream.
  70.  
  71.        bzcat  (or bzip2 -dc ) decompresses all specified files to
  72.        the standard output.
  73.  
  74.        Compression is always performed, even  if  the  compressed
  75.        file  is slightly larger than the original.  Files of less
  76.        than about one hundred bytes tend to get larger, since the
  77.        compression  mechanism  has  a  constant  overhead  in the
  78.        region of 50 bytes.  Random data (including the output  of
  79.        most  file  compressors)  is  coded at about 8.05 bits per
  80.        byte, giving an expansion of around 0.5%.
  81.  
  82.        As a self-check for your  protection,  bzip2  uses  32-bit
  83.        CRCs  to make sure that the decompressed version of a file
  84.        is identical to the original.  This guards against corrup-
  85.        tion  of  the compressed data, and against undetected bugs
  86.        in bzip2 (hopefully very unlikely).  The chances  of  data
  87.        corruption  going  undetected  is  microscopic,  about one
  88.        chance in four billion for each file processed.  Be aware,
  89.        though,  that  the  check occurs upon decompression, so it
  90.        can only tell you that that something is wrong.  It  can't
  91.        help  you recover the original uncompressed data.  You can
  92.        use bzip2recover to  try  to  recover  data  from  damaged
  93.        files.
  94.  
  95.        Return  values:  0  for a normal exit, 1 for environmental
  96.        problems (file not found, invalid flags, I/O errors,  &c),
  97.        2 to indicate a corrupt compressed file, 3 for an internal
  98.        consistency error (eg, bug) which caused bzip2 to panic.
  99.  
  100.  
  101. MEMORY MANAGEMENT
  102.        Bzip2 compresses large files in blocks.   The  block  size
  103.        affects  both  the  compression  ratio  achieved,  and the
  104.        amount of memory needed both for  compression  and  decom-
  105.        pression.   The flags -1 through -9 specify the block size
  106.        to be 100,000 bytes through 900,000  bytes  (the  default)
  107.        respectively.   At decompression-time, the block size used
  108.        for compression is read from the header of the  compressed
  109.        file, and bunzip2 then allocates itself just enough memory
  110.        to decompress the file.  Since block sizes are  stored  in
  111.        compressed  files,  it follows that the flags -1 to -9 are
  112.        irrelevant  to  and  so  ignored   during   decompression.
  113.  
  114.        Compression  and decompression requirements, in bytes, can
  115.        be estimated as:
  116.  
  117.              Compression:   400k + ( 7 x block size )
  118.  
  119.              Decompression: 100k + ( 4 x block size ), or
  120.                             100k + ( 2.5 x block size )
  121.  
  122.        Larger  block  sizes  give  rapidly  diminishing  marginal
  123.        returns;  most of the compression comes from the first two
  124.        or three hundred k of block size, a fact worth bearing  in
  125.        mind  when  using  bzip2  on  small  machines.  It is also
  126.        important to  appreciate  that  the  decompression  memory
  127.        requirement  is  set  at compression-time by the choice of
  128.        block size.
  129.  
  130.        For files compressed with the  default  900k  block  size,
  131.        bunzip2  will require about 3700 kbytes to decompress.  To
  132.        support decompression of any file on a 4 megabyte machine,
  133.        bunzip2  has  an  option to decompress using approximately
  134.        half this amount of memory, about 2300 kbytes.  Decompres-
  135.        sion  speed  is also halved, so you should use this option
  136.        only where necessary.  The relevant flag is -s.
  137.  
  138.        In general, try and use the largest block size memory con-
  139.        straints  allow,  since  that  maximises  the  compression
  140.        achieved.  Compression and decompression speed are  virtu-
  141.        ally unaffected by block size.
  142.  
  143.        Another  significant point applies to files which fit in a
  144.        single block -- that  means  most  files  you'd  encounter
  145.        using  a  large  block  size.   The  amount of real memory
  146.        touched is proportional to the size of the file, since the
  147.        file  is smaller than a block.  For example, compressing a
  148.        file 20,000 bytes long with the flag  -9  will  cause  the
  149.        compressor  to  allocate  around 6700k of memory, but only
  150.        touch 400k + 20000 * 7 = 540 kbytes of it.  Similarly, the
  151.        decompressor  will  allocate  3700k  but only touch 100k +
  152.        20000 * 4 = 180 kbytes.
  153.  
  154.        Here is a table which summarises the maximum memory  usage
  155.        for  different  block  sizes.   Also recorded is the total
  156.        compressed size for 14 files of the Calgary Text  Compres-
  157.        sion  Corpus totalling 3,141,622 bytes.  This column gives
  158.        some feel for how  compression  varies  with  block  size.
  159.        These  figures  tend to understate the advantage of larger
  160.        block sizes for larger files, since the  Corpus  is  domi-
  161.        nated by smaller files.
  162.  
  163.                   Compress   Decompress   Decompress   Corpus
  164.            Flag     usage      usage       -s usage     Size
  165.  
  166.             -1      1100k       500k         350k      914704
  167.             -2      1800k       900k         600k      877703
  168.             -3      2500k      1300k         850k      860338
  169.             -4      3200k      1700k        1100k      846899
  170.             -5      3900k      2100k        1350k      845160
  171.             -6      4600k      2500k        1600k      838626
  172.             -7      5400k      2900k        1850k      834096
  173.             -8      6000k      3300k        2100k      828642
  174.             -9      6700k      3700k        2350k      828642
  175.  
  176.  
  177. OPTIONS
  178.        -c --stdout
  179.               Compress or decompress to standard output.  -c will
  180.               decompress multiple files to stdout, but will  only
  181.               compress a single file to stdout.
  182.  
  183.        -d --decompress
  184.               Force  decompression.  bzip2, bunzip2 and bzcat are
  185.               really the same program,  and  the  decision  about
  186.               what  actions to take is done on the basis of which
  187.               name is used.  This flag overrides that  mechanism,
  188.               and forces bzip2 to decompress.
  189.  
  190.        -z --compress
  191.               The  complement  to -d: forces compression, regard-
  192.               less of the invokation name.
  193.  
  194.        -t --test
  195.               Check integrity of the specified file(s), but don't
  196.               decompress  them.   This  really  performs  a trial
  197.               decompression and throws away the result.
  198.  
  199.        -f --force
  200.               Force overwrite of output files.   Normally,  bzip2
  201.               will not overwrite existing output files.
  202.  
  203.        -k --keep
  204.               Keep  (don't delete) input files during compression
  205.               or decompression.
  206.  
  207.        -s --small
  208.               Reduce memory usage, for compression, decompression
  209.               and  testing.   Files  are  decompressed and tested
  210.               using a modified algorithm which only requires  2.5
  211.               bytes  per  block byte.  This means any file can be
  212.               decompressed in 2300k of memory,  albeit  at  about
  213.               half the normal speed.
  214.  
  215.               During  compression,  -s  selects  a  block size of
  216.               200k, which limits memory use to  around  the  same
  217.               figure,  at  the expense of your compression ratio.
  218.               In short, if your  machine  is  low  on  memory  (8
  219.               megabytes  or  less),  use  -s for everything.  See
  220.               MEMORY MANAGEMENT above.
  221.  
  222.        -v --verbose
  223.               Verbose mode -- show the compression ratio for each
  224.               file  processed.   Further  -v's  increase the ver-
  225.               bosity level, spewing out lots of information which
  226.               is primarily of interest for diagnostic purposes.
  227.  
  228.        -L --license -V --version
  229.               Display  the  software  version,  license terms and
  230.               conditions.
  231.  
  232.        -1 to -9
  233.               Set the block size to 100 k, 200 k ..  900  k  when
  234.               compressing.   Has  no  effect  when decompressing.
  235.               See MEMORY MANAGEMENT above.
  236.  
  237.        --repetitive-fast
  238.               bzip2 injects some small  pseudo-random  variations
  239.               into  very  repetitive  blocks  to limit worst-case
  240.               performance during compression.   If  sorting  runs
  241.               into  difficulties,  the  block  is randomised, and
  242.               sorting is restarted.  Very roughly, bzip2 persists
  243.               for  three  times  as  long as a well-behaved input
  244.               would take before resorting to randomisation.  This
  245.               flag makes it give up much sooner.
  246.  
  247.        --repetitive-best
  248.               Opposite  of  --repetitive-fast;  try  a lot harder
  249.               before resorting to randomisation.
  250.  
  251.  
  252. RECOVERING DATA FROM DAMAGED FILES
  253.        bzip2 compresses files in blocks, usually 900kbytes  long.
  254.        Each block is handled independently.  If a media or trans-
  255.        mission error causes a multi-block  .bz2  file  to  become
  256.        damaged,  it  may  be  possible  to  recover data from the
  257.        undamaged blocks in the file.
  258.  
  259.        The compressed representation of each block  is  delimited
  260.        by  a  48-bit pattern, which makes it possible to find the
  261.        block boundaries with reasonable  certainty.   Each  block
  262.        also  carries its own 32-bit CRC, so damaged blocks can be
  263.        distinguished from undamaged ones.
  264.  
  265.        bzip2recover is a  simple  program  whose  purpose  is  to
  266.        search  for blocks in .bz2 files, and write each block out
  267.        into its own .bz2 file.  You can then use bzip2 -t to test
  268.        the integrity of the resulting files, and decompress those
  269.        which are undamaged.
  270.  
  271.        bzip2recover takes a single argument, the name of the dam-
  272.        aged file, and writes a number of files "rec0001file.bz2",
  273.        "rec0002file.bz2", etc, containing the  extracted  blocks.
  274.        The  output  filenames  are  designed  so  that the use of
  275.        wildcards in subsequent processing -- for example,  "bzip2
  276.        -dc  rec*file.bz2  > recovered_data" -- lists the files in
  277.        the "right" order.
  278.  
  279.        bzip2recover should be of most use dealing with large .bz2
  280.        files,  as  these will contain many blocks.  It is clearly
  281.        futile to use it on damaged single-block  files,  since  a
  282.        damaged  block  cannot  be recovered.  If you wish to min-
  283.        imise any potential data loss through media  or  transmis-
  284.        sion errors, you might consider compressing with a smaller
  285.        block size.
  286.  
  287.  
  288. PERFORMANCE NOTES
  289.        The sorting phase of compression gathers together  similar
  290.        strings  in  the  file.  Because of this, files containing
  291.        very long runs of  repeated  symbols,  like  "aabaabaabaab
  292.        ..."   (repeated   several  hundred  times)  may  compress
  293.        extraordinarily slowly.  You can use the -vvvvv option  to
  294.        monitor progress in great detail, if you want.  Decompres-
  295.        sion speed is unaffected.
  296.  
  297.        Such pathological cases seem rare in  practice,  appearing
  298.        mostly in artificially-constructed test files, and in low-
  299.        level disk images.  It may be inadvisable to use bzip2  to
  300.        compress  the  latter.   If you do get a file which causes
  301.        severe slowness in compression, try making the block  size
  302.        as small as possible, with flag -1.
  303.  
  304.        bzip2  usually  allocates  several  megabytes of memory to
  305.        operate in, and then charges all over it in a fairly  ran-
  306.        dom  fashion.   This means that performance, both for com-
  307.        pressing and decompressing, is largely determined  by  the
  308.        speed  at  which  your  machine  can service cache misses.
  309.        Because of this, small changes to the code to  reduce  the
  310.        miss  rate  have  been observed to give disproportionately
  311.        large performance improvements.  I imagine bzip2 will per-
  312.        form best on machines with very large caches.
  313.  
  314.  
  315. CAVEATS
  316.        I/O  error  messages  are not as helpful as they could be.
  317.        Bzip2 tries hard to detect I/O errors  and  exit  cleanly,
  318.        but  the  details  of  what  the problem is sometimes seem
  319.        rather misleading.
  320.  
  321.        This manual page pertains to version 0.9.0 of bzip2.  Com-
  322.        pressed  data created by this version is entirely forwards
  323.        and backwards compatible with the previous public release,
  324.        version  0.1pl2,  but  with the following exception: 0.9.0
  325.        can correctly decompress multiple concatenated  compressed
  326.        files.   0.1pl2  cannot do this; it will stop after decom-
  327.        pressing just the first file in the stream.
  328.  
  329.        Wildcard expansion for Windows 95 and NT is flaky.
  330.  
  331.        bzip2recover uses 32-bit integers to represent  bit  posi-
  332.        tions  in compressed files, so it cannot handle compressed
  333.        files more than 512 megabytes long.  This could easily  be
  334.        fixed.
  335.  
  336.  
  337. AUTHOR
  338.        Julian Seward, jseward@acm.org.
  339.        http://www.muraroa.demon.co.uk
  340.  
  341.        The ideas embodied in bzip2 are due to (at least) the fol-
  342.        lowing people: Michael Burrows and David Wheeler (for  the
  343.        block  sorting  transformation), David Wheeler (again, for
  344.        the Huffman coder), Peter Fenwick (for the structured cod-
  345.        ing model in the original bzip, and many refinements), and
  346.        Alistair Moffat, Radford Neal  and  Ian  Witten  (for  the
  347.        arithmetic  coder  in  the  original  bzip).   I  am  much
  348.        indebted for their help, support and advice.  See the man-
  349.        ual  in the source distribution for pointers to sources of
  350.        documentation.  Christian von Roques encouraged me to look
  351.        for  faster sorting algorithms, so as to speed up compres-
  352.        sion.  Bela Lubkin encouraged me to improve the worst-case
  353.        compression performance.  Many people sent patches, helped
  354.        with portability problems, lent machines, gave advice  and
  355.        were generally helpful.
  356.